from django.contrib.auth.models import Group
from rest_framework import serializers

from users.models import User

class AdminSerializer(serializers.ModelSerializer):
    class Meta:
        model=User
        fields="__all__"
        extra_kwargs={
            'password':{
                'write_only': True
            }
        }

    def create(self,validate_data):

        validate_data['is_staff'] = True

        admin = super().create(validate_data)
        password = validate_data['password']
        admin.set_password(password)
        admin.save()
        return admin

